#include ("/_includes/_layout.html")
#@layout("地址管理", "wxmall,点步科技", "Wxmall社区","wxmall")
<style>
.weui_cell_hd{
	margin-right: 10px;
)
.edit{
	display: block;
	width: 15px;
	height: 15px;
	background-image: url(#(webctx)/resources/images/rename.png);
	background-repeat: no-repeat;
	background-size: 100%;
)
.weui_cell_bd.weui_cell_primary{
	font-size: 14px;
	line-height: 18px;
)
.site-default{
	color: #3482FF;
)
.weui_panel a.weui_panel_ft{
	color: #404040;
)
.weui_panel a.add-site:after{
	top: 30%;
	right: 9px;
	border: 0;
	width: 25px;
	height: 25px;
	background: url("#(webctx)/resources/images/add-collaborators.png") no-repeat;
	background-size: 100%;
	transform: initial;
)
.weui_panel a.select:after{
	top: 40%;
	right: 20px;
	height: 13px;
	width: 13px;
)
</style>
<div class="weui-cells weui-cells_checkbox" style="font-size: 12px;">
	#if(receiverList??)
		#for(item : receiverList)
			#if(item.isDefault == true)
			<div class="weui-cell">
				<div class="weui-cell__hd">
				    <label class="weui-check__label" for="#(item.id)">
				        <input type="radio" class="weui-check" name="r_checkbox1" id="#(item.id)" checked="checked">
				        <i class="weui-icon-checked"></i>
				    </label>    
			    </div>
			    <a class="weui-cell__bd weui-cell-primary abd" data-abd-id="#(item.id)">
			        <p class="address_input"><span class="site-default">【默认】</span>#(item.address)</p>
			        <p class="areaName_input">#(item.areaName)</p>
			        <p><span class="cons_input">#(item.receiverName)</span>&nbsp;<span class="phone_input">#(item.phone)</span></p>
			    </a>
			    <a class="edit" data-r-id="#(item.id)" href="#(webctx)/receiver/editView?id=#(item.id)">编辑</a>
			</div>
			#else
			<div class="weui-cell">
			    <div class="weui-cell__hd">
			    	<label class="weui-check__label" for="#(item.id)">
			        	<input type="radio" class="weui-check" name="r_checkbox1" id="#(item.id)">
			        	<i class="weui-icon-checked"></i>
			        </label>
			    </div>
			    <a class="weui-cell__bd weui-cell-primary abd" data-abd-id="#(item.id)">
			        <p class="address_input">#(item.address)</p>
			        <p class="areaName_input">#(item.areaName)</p>
			        <p><span class="cons_input">#(item.receiverName)</span>&nbsp;<span class="phone_input">#(item.phone)</span></p>
			    </a>
			    <a class="edit" data-r-id="#(item.id)" href="#(webctx)/receiver/editView?id=#(item.id)">编辑</a>&nbsp;&nbsp;
			    <a class="delete" data-r-id="#(item.id)" href="javascript:void(0)">删除</a>
			</div>
			#end
		#end
	#end
	<div class="content-padded" style="padding-bottom: 10px;">
		<a id="add_receiver" href="#(webctx)/receiver/addView" class="weui-btn weui-btn_default d_confirm_btn" style="color: black;">新增收货地址</a>
	</div>
</div>
<!--手机端script需要加载后方-->
#include ("/_includes/menus.html")
<script type="text/javascript">
$(function(){
	$("#add_receiver").click(function(){
		$.closePopup();
		$.showLoading("正在加载...");
		$("#address_add_div").load("#(webctx)/receiver/add", function(){
			$.hideLoading();
			$("#add_half_dialog").popup();
		});
	});
		
$(".edit").click(function(){
	$.closePopup();
	$.showLoading("正在加载...");
	$("#address_add_div").load("#(webctx)/receiver/edit?id="+$(this).attr("data-r-id"), function(){
		$.hideLoading();
		$("#add_half_dialog").popup();
	});
});
		

$("input:radio[name='r_checkbox1']").each(function() {
	  if($("#select_receiverId").val() == $(this).attr("id")){
		  $(this).attr("checked", true);
		  return;
	  }
	});
})
	
$(".delete").click(function(){
	var id = $(this).attr("data-r-id");
	$.modal({
		  title: "提示",
		  text: "确定要删除吗?",
		  buttons: [
		    { text: "确定", 
		    	onClick: function(){
		    		$.post("#(webctx)/receiver/delete", {id:id}, function(resp){
		    			if(resp.code != 200){
		    				$.toast(resp.msg, "text");
		    			}else{
		    				location.href='#(webctx)/receiver/view';
		    			}
		    		});
		    	}
		    },
		    {text : "取消" }
		  ]
	})
});
	
</script>
